home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / TSPA3370.ZIP / TSUNTENV.INT < prev    next >
Text File  |  1993-07-23  |  3KB  |  85 lines

  1. (*
  2. Timo Salmi UNiT ENV
  3. A Turbo Pascal unit of file environment handling routines
  4. All rights reserved 8-Feb-92, 13-Jun-92, 20-Aug-92, 23-Jul-92
  5.  
  6. This unit may be used and distributed freely for PRIVATE, NON-COMMERCIAL,
  7. NON-INSTITUTIONAL purposes, provided it is not changed in any way, and
  8. that you make a proper attribution. For ANY other usage, such as use in a
  9. business enterprise or a university, contact the author for the terms of
  10. registration.
  11.  
  12. The units are under development. Comments and contacts are solicited. If
  13. you have any questions, please do not hesitate to use electronic mail for
  14. communication.
  15. InterNet address: ts@uwasa.fi           (preferred)
  16. Bitnet address:   SALMI@FINFUN.BITNET
  17.  
  18. The author shall not be liable to the user for any direct, indirect or
  19. consequential loss arising from the use of, or inability to use, any unit,
  20. program or file howsoever caused. No warranty is given that the units and
  21. programs will work under all circumstances.
  22.  
  23. Timo Salmi
  24. Professor of Accounting and Business Finance
  25. Faculty of Accounting & Industrial Management; University of Vaasa
  26. P.O. BOX 297, FI-65101 Vaasa, Finland
  27.  
  28. Added 13-Jun-92
  29.  SETENVSH
  30. *)
  31.  
  32. unit TSUNTENV;
  33.  
  34. (* ======================================================================= *)
  35.                           interface
  36. (* ======================================================================= *)
  37.  
  38. uses Dos;
  39.  
  40. (* Get the size of the parent environment. Draws very heavily on the
  41.    article in the PC Magazine Vol. 11, No. 1, pp. 425-427, but also
  42.    includes some programming of my own *)
  43. function ENVSIZFN : word;
  44.  
  45. (* Get the size of the parent environment that is already used up.
  46.    This part of the environment code is primarily due to yours
  47.    truly, and is based on the format of the environment table which
  48.    is name=value1<nul>name=value2<nul>...name=valueN<nul><nul> *)
  49. function ENVUSEFN : word;
  50.  
  51. (* Get the starting segment address of the parent environment. Draws very
  52.    heavily on the article in the PC Magazine Vol. 11, No. 1, p. 425-427,
  53.    but also includes some ideas of my own.
  54.    Returns 0 if the address cannot be found *)
  55. function ENVADDFN : word;
  56.  
  57. (* Set the value of an environment variable. Note that the name of
  58.    the environment variable is CASE SENSITIVE. E.g. you can put
  59.    both COMSPEC and comspec in your environment.  (Don't.)
  60.    Use upper case throughout to be on the safe side.
  61.    This part of the environment code is solely my own (un)doing.
  62.    Status values:
  63.     0 = No errors detected
  64.     1 = Syntax error (Correct syntax: VARIABLE=VALUE)
  65.     2 = Out of environment space
  66.     3 = Missed the variable or the environment
  67.    Note that this takes effect only after the program has terminated!
  68.    Also note that any trailing white spaces are included:
  69.    'VARIABLE=VALUE' and 'VARIABLE = VALUE' are not the same thing.
  70. *)
  71. procedure SETENV (EnvVar : string; var status : byte);
  72.  
  73. (* Write the parent environment table on stdout *)
  74. procedure SHOWENV;
  75.  
  76. (* Set a temporary value for an environment variable.
  77.    SETENVSH should take effect for the duration of shelling to dos.
  78.    This was a complicated task with parts of code scraped from
  79.    here and there so be a bit wary.
  80.    Everything is made upper case.
  81.    Note the slightly differing syntax from SETENV.
  82. *)
  83. procedure SETENVSH (envvar, envval : string);
  84.  
  85.